package com.tuanbiao.ui;

import android.content.Context;
import android.content.Intent;

import com.tuanbiao.base.mvp.BasePresenterActivity;
import com.tuanbiao.controllers.SettingMacController;
import com.tuanbiao.databinding.ActivitySettingMacBinding;
import com.tuanbiao.models.SettingMacModel;
import com.tuanbiao.presenter.setting.SettingMacPresenter;
import com.tuanbiao.utils.ClickUtil;


public class SettingMacActivity extends BasePresenterActivity<SettingMacPresenter, ActivitySettingMacBinding> implements SettingMacController.View {
//    private String mIMEI;
//    private String mMac;

    public static void start(Context context) {
        Intent starter = new Intent(context, SettingMacActivity.class);
        context.startActivity(starter);
    }


    @Override
    protected ActivitySettingMacBinding getBindingView() {
        return ActivitySettingMacBinding.inflate(getLayoutInflater());
    }

    @Override
    protected void initView() {
        binding.ivToolbarBack.setOnClickListener(getBackListener());
        binding.btnCommit.setOnClickListener(view -> {
            if (ClickUtil.isFastClick()) {
                return;
            }
            mPresenter.setMacAndIMEI(getString(binding.etMac), getString(binding.etImei));
        });
        binding.btnResetMac.setOnClickListener(view -> {
            if (ClickUtil.isFastClick()) {
                return;
            }
            binding.etMac.setText(mPresenter.getOriginalMac());
        });
        binding.btnResetImei.setOnClickListener(view -> {
            if (ClickUtil.isFastClick()) {
                return;
            }
            binding.etImei.setText(mPresenter.getOriginalIMEI());
        });
//        binding.sbMac.setOnClickListener(view -> {
//            showMacDialog();
//        });
//        binding.sbImei.setOnClickListener(view -> {
//            showIMEIDialog();
//        });
    }

    @Override
    protected SettingMacPresenter createPresenter() {
        return new SettingMacPresenter(new SettingMacModel(), this);
    }

    @Override
    public void showMacAndIMEI(String mac, String IMEI) {
        binding.etMac.setText(mac);
        binding.etImei.setText(IMEI);
    }


//    private void showMacDialog() {
//        new ResetDialog.Builder(getActivity())
//                .setTitle("设置MAC地址")
//                .setCanceledOnTouchOutside(false)
//                .setInput(StringUtils.nullToEmpty(mMac))
//                .setListener(new ResetDialog.OnResetClickListener() {
//
//                    @Override
//                    public void onConfirm(String content, BaseDialog dialog) {
//                        if (!TextUtils.isEmpty(content)) {
//                            mPresenter.setMac(content);
//                            dialog.dismiss();
//                        } else {
//                            showMessage("请输入MAC地址");
//                        }
//                    }
//
//                    @Override
//                    public void onReset(ResetDialog.Builder builder) {
//                        builder.setInput(mPresenter.getOriginalMac());
//                    }
//
//                    @Override
//                    public void onClose(BaseDialog dialog) {
//                        dialog.dismiss();
//                    }
//
//                }).show();
//    }
//
//    private void showIMEIDialog() {
//        new ResetDialog.Builder(getActivity())
//                .setTitle("设置IMEI地址")
//                .setCanceledOnTouchOutside(false)
//                .setInput(StringUtils.nullToEmpty(mIMEI))
//                .setListener(new ResetDialog.OnResetClickListener() {
//                    @Override
//                    public void onConfirm(String content, BaseDialog dialog) {
//                        if (!TextUtils.isEmpty(content)) {
//                            mPresenter.setIMEI(content);
//                            dialog.dismiss();
//                        } else {
//                            showMessage("请输入IMEI地址");
//                        }
//                    }
//
//                    @Override
//                    public void onReset(ResetDialog.Builder builder) {
//                        builder.setInput(mPresenter.getOriginalIMEI());
//                    }
//
//                    @Override
//                    public void onClose(BaseDialog dialog) {
//                        dialog.dismiss();
//                    }
//                }).show();
//    }
}